/**
 * Create a new Iterator instance.
 * Inherit from JObject
 * @author	Wan Changhua
 * @version	2.01, 10/23/05 $Id: Iterator.js 35 2008-03-02 17:01:34Z dsonet $
 * @class This is the iterator class.
 * @constructor
 */
function Iterator ()
{
	if(arguments.length == 1){
		var obj = arguments[0];
		if(obj instanceof Iterator)
		{
			return obj;
		}
		else if(Type.isArray(obj))
		{
			this._value = obj;
		}
		else
		{
			this._value = [obj];
		}
	}
	else
	{
		this._value = arguments;
	}
}

var $p = Iterator.prototype;

/**
 * 访问元素的指针位置
 * @id Iterator.prototype._index
 * @private
 * @typeof number
 */
$p._index = 0;

/**
 * Returns <tt>true</tt> if the iteration has more elements.
 * @id Iterator.prototype.hasNext
 * @public
 * @return {boolean} <code>true</code> if it has next;
 *		  <code>false</code> otherwise.
 */
$p.hasNext = function()
{
	return (this._value.length > this._index);
}

/**
 * Returns the next element in the iteration.
 * @id Iterator.prototype.next
 * @public
 * @return {mixed} the next element in the iteration.
 */
$p.next = function()
{
	return this._value[this._index++];
}

/**
 * Returns an array containing all of the elements in this iterator
 * @id Iterator.prototype.toArray
 * @return {array} array
 * @public
 */
$p.toArray = function ()
{
	return this._value.concat([]);
}
$p = null;